package Day12;

import Day09.UsernameNotFoundException;

public class Girl {
    public String name;
    public int age;
    public Girl() {
    }

    public Girl(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name)  throws UsernameException{
        int len = name.length();
        if(len < 3 || len > 10){
            throw new UsernameException("字数超过限制");
        }
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws BadException {
        if(age < 18 || age > 40){
            throw new BadException("年龄超出了限制");
        }
        this.age = age;
    }
}
